<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点亮/关闭灯泡</title>
</head>

<body>
    <!-- 点亮灯泡 -->
    <script>
        function changeImage() {
            // 检索img的src属性值包不包含bulbon字符串，存在更新src为bulboff.gif；匹配不到，src值更新为bulbon.gif
            element = document.getElementById('myimage');
            if (element.src.match("bulbon")) {
                element.src = "images/pic_bulboff.gif";
            } else {
                element.src = "images/pic_bulbon.gif";
            }
        }
    </script>
    <img loading="lazy" id="myimage" onclick="changeImage()" src="images/pic_bulboff.gif" width="100" height="180" />
</body>

</html>